﻿using System;

public interface IShape
{
   double GetArea();
   bool IsValid();
}

public class Rectangle : IShape
{
   private double length;
   private double width;

   public Rectangle(double length, double width)
   {
       this.length = length;
       this.width = width;
   }

   public double Length
   {
       get { return length; }
       set { length = value; }
   }

   public double Width
   {
       get { return width; }
       set { width = value; }
   }

   public double GetArea()
   {
       return length * width;
   }

   public bool IsValid()
   {
       return length > 0 && width > 0;
   }
}

public class Square : Rectangle
{
   public Square(double side) : base(side, side)
   {
   }

   public double Side
   {
       get { return Length; }
       set { Length = value; Width = value; }
   }
}

public class Triangle : IShape
{
   private double side1;
   private double side2;
   private double side3;

   public Triangle(double side1, double side2, double side3)
   {
       this.side1 = side1;
       this.side2 = side2;
       this.side3 = side3;
   }

   public double Side1
   {
       get { return side1; }
       set { side1 = value; }
   }

   public double Side2
   {
       get { return side2; }
       set { side2 = value; }
   }

   public double Side3
   {
       get { return side3; }
       set { side3 = value; }
   }

   public double GetArea()
   {
       double s = (side1 + side2 + side3) / 2;
       return Math.Sqrt(s * (s - side1) * (s - side2) * (s - side3));
   }

   public bool IsValid()
   {
       return side1 > 0 && side2 > 0 && side3 > 0 && (side1 + side2 > side3) && (side1 + side3 > side2) && (side2 + side3 > side1);
   }
}
